<template>
	<view>
		<view>
		    <view class="datitle">
		        <image src="https://myr.wissun.net/static/newhome/img/iconhome.png"></image>
		        <view class="textf">我的地址</view>
		    </view>
		    <view class="address" v-for="item in addresslist">
		        <view class="title">{{item.detail}}</view>
		        <view class="shenshiqu">
		            <view class="qushi">{{item.ad1}}</view>
		            <view class="qushi">{{item.ad2}}</view>
		            <view class="qushi">{{item.ad3}}</view>
		        </view>
		        <view class="shenshiqu">
		            <view class="qushi">{{item.rec_user_name}}</view>
		            <view class="qushi">{{item.rec_mobile}}</view>
		        </view>
		        <view class="iconedit" @click="editaddr(item)" >
		            <image  src="https://myr.wissun.net/static/newhome/img/iconedit.png"></image>
		        </view>
		    </view>
		    <view class="addbtn" @click="addaddress">
		        <view class="newaddress">新建收货地址</view>
		    </view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				addresslist:[],
				page:1,
				page_size:10
			}
		},
		onShow() {
			this.getuseaddress()
		},
		onHide(){
			this.page=1;
		},
		methods: {
			 getuseaddress(){
				var postdata={}
				var t=this
				postdata.page=this.page
				postdata.page_size=this.page_size
				postdata.user_id=uni.getStorageSync("user_id")
				this.request('/api/address/get_address_list', postdata,"post").then(ret => {
					console.log(ret)
					if(ret.info.length > 0){
						postdata.page++
					}
					t.page++;
					t.addresslist=t.addresslist.concat(ret.info)
					
				})
			},
			addaddress(){
				uni.navigateTo({
				  url: '/pages/address/add',
				})
			},
			editaddr(e){        
				var id=e.id
				uni.navigateTo({
					url: '/pages/address/add?id='+id
				  })
			},
		}
	}
</script>

<style>
.shenshiqu{
    font-size: 14px;
    color: #A2A2A2;
    display: flex;
}
.title{
    width: 80%;
    padding:10rpx;
    padding-bottom: 0px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.qushi{margin: 10rpx 10rpx 0px 10rpx;}
.address{
    width: calc(100% - 60px);
    margin: 0 auto;
    height: 171rpx;
    border-bottom: 1rpx solid #eee;
    position:relative;
}
.iconedit{
    position: absolute;
    right: 20px;
    top: 30px;
}
.iconedit image{
    width: 24px;
    height: 20px;
}
.datitle{
    display: flex;
    margin-left: 15px;
}
.textf{
    font-size: 14px;
    height: 40px;
    line-height: 40px;
    padding-left: 2px;
    color: #A2A2A2;
}
.datitle image{
    width: 20px;
    height: 18px;
    margin-top: 10px;
}
.addbtn{
    width: 100%;
    text-align: center;
    margin:0 auto;
    font-size: 14px;
    position: fixed;
    bottom: 40px;
}
.newaddress{
    text-align: center;
    border-radius: 30px;
    background-color: #0DB8C0;
    width: 150px;
    height: 35px;
    line-height: 35px;
    color: #fff;
    margin:0 auto;
}
</style>
